# Adds a schema to the schema repository with status INTERNAL.

Adds a schema to the schema repository. The schemaIdentity must be unique. The `authority`, `source` and `entityType` will be registered if not present. If lower minor versions are registered the service validates the new schema against breaking changes; if breaking changes are discovered the request fails.  **Note:** The schema must not reference other schemas with status `DEVELOPMENT`. By default scope to a schema will be set as `INTERNAL`  **Required roles** 'users.datalake.editors' or 'users.datalake.admins' groups to create schema.

Endpoint: POST /schema
Version: 1.0.0
Security: bearer

## Security:

  - `bearer` (unknown)
    http bearer JWT

## Header parameters:

  - `data-partition-id` (string, required)
    desired data partition id

## Request body:

  - `application/json` (unknown)
    Schema description and schema to add

## Request fields (application/json):

  - `schema` (object, required)

  - `schemaInfo` (object, required)
    Schema info including status, creation and schemaIdentity

  - `schemaInfo.createdBy` (string)
    The user who created the schema. This value is taken from API caller token.
    Example: user@opendes.com

  - `schemaInfo.dateCreated` (string)
    The UTC date time of the entity creation
    Example: 2019-05-23 11:16:03+00:00

  - `schemaInfo.schemaIdentity` (object, required)
    Schema authority source and type description

  - `schemaInfo.schemaIdentity.authority` (string, required)
    Entity authority
    Example: osdu

  - `schemaInfo.schemaIdentity.entityType` (string, required)
    EntityType Code
    Example: wellbore

  - `schemaInfo.schemaIdentity.id` (string)
    A read-only system defined id used for referencing of a schema.
    Example: osdu:wks:wellbore:1.0.0

  - `schemaInfo.schemaIdentity.schemaVersionMajor` (integer, required)
    Major Schema Version Number
    Example: 1

  - `schemaInfo.schemaIdentity.schemaVersionMinor` (integer, required)
    Minor Schema Version Number
    Example: 1

  - `schemaInfo.schemaIdentity.schemaVersionPatch` (integer, required)
    Patch Schema Version Number
    Example: 0

  - `schemaInfo.schemaIdentity.source` (string, required)
    Entity source
    Example: wks

  - `schemaInfo.scope` (string)
    Schema Scope - is it internal or shared. This is a system defined attribute based on partition-id passed.
    Enum: "INTERNAL", "SHARED"

  - `schemaInfo.status` (string, required)
    Schema lifecycle status
    Enum: "PUBLISHED", "OBSOLETE", "DEVELOPMENT"

## Response 201:

  - `201` (unknown)
    Schema created

## Response 201 fields (application/json):

  - `createdBy` (string)
    The user who created the schema. This value is taken from API caller token.
    Example: user@opendes.com

  - `dateCreated` (string)
    The UTC date time of the entity creation
    Example: 2019-05-23 11:16:03+00:00

  - `schemaIdentity` (object, required)
    Schema authority source and type description

  - `schemaIdentity.authority` (string, required)
    Entity authority
    Example: osdu

  - `schemaIdentity.entityType` (string, required)
    EntityType Code
    Example: wellbore

  - `schemaIdentity.id` (string)
    A read-only system defined id used for referencing of a schema.
    Example: osdu:wks:wellbore:1.0.0

  - `schemaIdentity.schemaVersionMajor` (integer, required)
    Major Schema Version Number
    Example: 1

  - `schemaIdentity.schemaVersionMinor` (integer, required)
    Minor Schema Version Number
    Example: 1

  - `schemaIdentity.schemaVersionPatch` (integer, required)
    Patch Schema Version Number
    Example: 0

  - `schemaIdentity.source` (string, required)
    Entity source
    Example: wks

  - `scope` (string)
    Schema Scope - is it internal or shared. This is a system defined attribute based on partition-id passed.
    Enum: "INTERNAL", "SHARED"

  - `status` (string, required)
    Schema lifecycle status
    Enum: "PUBLISHED", "OBSOLETE", "DEVELOPMENT"

## Response 400:

  - `400` (unknown)
    Bad user input. Mandatory fields missing or unacceptable value passed to API

## Response 400 fields (application/json):

  - `error` (object)

  - `error.errors` (array)

  - `error.errors.message` (string)

  - `error.errors.reason` (string)

  - `error.errors.domain` (string)

  - `error.code` (integer)

  - `error.message` (string)

## Response 401:

  - `401` (unknown)
    Unknown or invalid user.

## Response 401 fields (application/json):

  - `error` (object)

  - `error.errors` (array)

  - `error.errors.message` (string)

  - `error.errors.reason` (string)

  - `error.errors.domain` (string)

  - `error.code` (integer)

  - `error.message` (string)

## Response 403:

  - `403` (unknown)
    User not authorised to access the API

## Response 403 fields (application/json):

  - `error` (object)

  - `error.errors` (array)

  - `error.errors.message` (string)

  - `error.errors.reason` (string)

  - `error.errors.domain` (string)

  - `error.code` (integer)

  - `error.message` (string)

